let arr = [];
for(var i = 0; i <6; i++){
    arr.push(function () {
    console.log(i);
    i++;  //注意这里
});
}
arr[0](); 
arr[0](); 
arr[0]();
arr[1]();
arr[1]();


const p1 = new Promise((resolve, reject) => {
  resolve('hello');
})
.then(result => result);

const p2 = new Promise((resolve, reject) => {
  resolve('error')
})
.then(result => result);

Promise.all([p1, p2])
.then(result => console.log(result))
.catch(e => console.log(1122));





const aa=new Promise((resolve,reject)=>{
  reject("132")
  
})

aa.then(a=>console.log(a),e=>console.log(e))

const p11 = new Promise((resolve, reject)=>{
  resolve("11111111111")
}).finally(()=>{console.log("finally")})

// const p2 = new Promise(function (resolve, reject) {
//   resolve(p1);
// })

p1.then((a)=>{
  console.log("a:"+a)
})

// p2.then((a)=>{
//   a.then(b=>console.log(b))
// })


// function aaa(d){
//   return new Promise((resolve,reject)=>{
//       console.log('running....')
//       let a='132';
//       // 
//       try {
//         //throw new Error("错了！")
//         a=e;
//         resolve(a);
        
//       } catch (error) {
//         reject(error)
//       }
      
//   })
// }

// var pro=aaa(-1)
// pro.then((a)=>console.log("执行完成:"+a),(err)=>console.log("失败了"+err))
// pro.then((a)=>console.log("执行完成:"+a),(err)=>console.log("失败了"+err))

// console.log('1')
// console.log('2')
// console.log('3')






